package com.wanbangee.marksystem.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wanbangee.marksystem.entities.MExamMarker;
import com.wanbangee.marksystem.service.QualityCheckService;

/**
 * 质量抽查
 * @author 王志雄
 *
 */

@RestController
@RequestMapping("quality")
public class QualityCheckController {
	
	@Autowired
	private QualityCheckService examMarkerInfoService;
	

	
	/**
	 * 获取图表信息
	 * @param examId
	 * @param examSubId
	 * @param topicNo
	 * @return
	 */
	@GetMapping("setting/selectQualityCharInfo/{examId}/{examSubId}/{topicNo}")
	public List<MExamMarker> selectQualityCharInfo(@PathVariable("examId")Integer examId,@PathVariable("examSubId")Integer examSubId,@PathVariable("topicNo")Integer topicNo) {
		return examMarkerInfoService.getMExamMarkerInfoByExamIdExamSubIdTopicNo(examId, examSubId, topicNo);
	}
	/**
	 * 查询是否为学科负责人
	 * @param examId
	 * @param examSubId
	 * @param teaId
	 * @return
	 */
	@GetMapping("setting/selectIsPrincipalTea/{examId}/{examSubId}/{teaId}")
	public Map selectIsPrincipalTea(@PathVariable("examId")Integer examId,@PathVariable("examSubId")Integer examSubId,@PathVariable("teaId")Integer teaId) {
		HashMap<String,Object> map = new HashMap<String, Object>();
		int count = examMarkerInfoService.selectIsPrincipalTea(examId, examSubId, teaId);
		
		if(count == 1) {
			map.put("code", 1001);
			map.put("result", true);
		}else {
			map.put("code", 10013);
			map.put("result", false);
		}
		return map;
	}
	/**
	 * 质量监控中，查询阅卷题目的详细信息
	 * @param markerId
	 * @return
	 */
	@GetMapping("setting/selectExamTeaInfo/{markerId}")
	public MExamMarker selectExamTeaInfo(@PathVariable("markerId")Integer markerId) {
		return examMarkerInfoService.selectMExamMarkerByMarkerId(markerId);
	}
	
	/**
	 * 获取质量监控阅卷人信息列表
	 * @param examId
	 * @param examSubId
	 * @param topicNo
	 * @return
	 */
	@GetMapping("setting/selectMExamMarkerList/{examId}/{examSubId}/{topicNo}")
	public List<MExamMarker> selectMExamMarkerByMarkerId(@PathVariable("examId")Integer examId,@PathVariable("examSubId")Integer examSubId,@PathVariable("topicNo")Integer topicNo) {
		return examMarkerInfoService.selectMExamMarkerList(examId, examSubId, topicNo);
	}
	
	/**
	 * 获取考试 Id 、考试科目 Id 、考试名、科目名
	 * 
	 */
	@GetMapping("setting/selectMExamMarkerByTeaIdAndSchId/{schId}/{teaId}")
	public List<MExamMarker> selectMExamMarkerByTeaIdAndSchId(@PathVariable("schId")Integer schId,@PathVariable("teaId")Integer teaId) {
		return examMarkerInfoService.selectMExamMarkerByTeaIdAndSchId(schId, teaId);
	}
	
}
